cmake_minimum_required(VERSION 3.0.2)
project(gpt_robot_description)

# 使用 C++11 标准
add_compile_options(-std=c++11)

# 查找 catkin 的包依赖项
find_package(catkin REQUIRED COMPONENTS
  roscpp
  controller_manager
  hardware_interface
  transmission_interface
  joint_limits_interface
  control_msgs
  control_toolbox
  pluginlib
  urdf
  diff_drive_controller
)

# 包的声明
catkin_package(
  INCLUDE_DIRS include
  LIBRARIES ${PROJECT_NAME}_hw_interface
  CATKIN_DEPENDS roscpp controller_manager hardware_interface transmission_interface joint_limits_interface control_msgs control_toolbox pluginlib urdf diff_drive_controller
)

# 包含头文件目录
include_directories(
  include
  ${catkin_INCLUDE_DIRS}
)

# 构建硬件接口类的库
add_library(${PROJECT_NAME}_hw_interface
  src/diffbot_hardware_interface.cpp
)

# 链接库文件
target_link_libraries(${PROJECT_NAME}_hw_interface
  ${catkin_LIBRARIES}
)

# 构建控制节点
add_executable(diffbot_control_node src/diffbot_control_node.cpp)

# 链接控制节点
target_link_libraries(diffbot_control_node
  ${PROJECT_NAME}_hw_interface
  ${catkin_LIBRARIES}
)

# 安装
install(TARGETS ${PROJECT_NAME}_hw_interface diffbot_control_node
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(DIRECTORY include/${PROJECT_NAME}/
  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)

install(DIRECTORY launch config
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
